package com.xbongbong.saas.domain.dao;

import com.xbongbong.saas.domain.entity.WorkOrderFlowNodeEntity;
import com.xbongbong.saas.domain.entity.ext.WorkOrderNodeAvgTimeEntityExt;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 *
 * @author 魏荣杰
 * @date 2019/3/11 19:40
 * @since v1.0
 * @version v1.0
 */
@Repository
@Mapper
public interface WorkOrderFlowNodeDao {

    Integer insert(WorkOrderFlowNodeEntity entity);

    Integer update(WorkOrderFlowNodeEntity entity);

    List<WorkOrderFlowNodeEntity> findEntitys(@Param("param") Map<String, Object> param);

    Integer getEntitysCount(@Param("param") Map<String, Object> param);

    List<String> getUserIdList(@Param("param") Map<String, Object> param);

    List<WorkOrderFlowNodeEntity> getNode(@Param("workOrderId") Long workOrderId, @Param("isNow") Integer isNow, @Param("corpid") String corpid);

    WorkOrderFlowNodeEntity getByKey(@Param("key") Long key, @Param("corpid") String corpid);

    WorkOrderFlowNodeEntity getPrevNode(@Param("param") Map<String,Object> params);

    /**
     * 获取平均耗时
     *
     * @param param 入参
     * @return com.xbongbong.saas.domain.entity.ext.WorkOrderNodeAvgTimeEntityExt
     * @author 徐俊杰
     * @date 2019/4/18 17:12
     * @since v1.0
     */
    List<WorkOrderNodeAvgTimeEntityExt> getStageAverageTime(@Param("param") Map<String, Object> param);

    WorkOrderFlowNodeEntity getLastNode(@Param("workOrderId") Long workOrderId, @Param("stageId") Long stageId, @Param("corpid") String corpid);

    List<Long> getWorkOrderIdResponsibleByUserIdIn(@Param("corpid") String corpid, @Param("userIdIn") List<String> userIdIn);

    List<Long> getTimeOutNode(@Param("corpid") String corpid, @Param("userIdIn") List<String> userIdIn);

    List<Long> getNotTimeOutNode(@Param("corpid") String corpid, @Param("userIdIn") List<String> userIdIn);

    List<Long> workOrderIdList(@Param("param") Map<String,Object> param);

    Integer deleteByWorkOrderIdIn(@Param("list") List<Long> workOrderIdIn, @Param("corpid") String corpid);

    List<WorkOrderFlowNodeEntity> getWorkOrderFlowStatus(@Param("corpid") String corpid, @Param("workOrderList") List<Long> workOrderIdIn, @Param("userId") String userId);

    List<WorkOrderFlowNodeEntity> getWorkOrderFlowStatus1(@Param("corpid") String corpid, @Param("workOrderList") List<Long> workOrderIdIn, @Param("userIdList") List<String> userIdIn);

    WorkOrderFlowNodeEntity getLastNodeByStageList(@Param("workOrderId") Long workOrderId, @Param("stageIdIn") List<Long> preStageList, @Param("corpid") String corpid);
}
